Skip to content

Replace Vercel Workflow with Supabase Queues + duplicate detection#389

Open
pontusab wants to merge 2 commits into
mainfrom
feat/replace-workflow-with-supabase-queues
Open

Replace Vercel Workflow with Supabase Queues + duplicate detection#389
pontusab wants to merge 2 commits into
mainfrom
feat/replace-workflow-with-supabase-queues

Conversation

@pontusab
Copy link
Copy Markdown
Collaborator

@pontusab pontusab commented May 15, 2026

Summary

  • Moves the plugin security scan off the workflow package onto a Postgres-native pgmq queue drained by a 1-min Vercel cron (/api/queue/plugin-scans/drain, maxDuration=800s, VT=900s, bury after 5 attempts). The Workflow runtime has been unreliable in prod; this replaces it with infrastructure we already operate.
  • Server actions now enqueuePluginScan(...) and fire a non-blocking after() kick at the drain route, so freshly submitted plugins start scanning within milliseconds. The cron is the durability/retry safety net.
  • Adds duplicate detection in the same flow: find_similar_plugins RPC (pg_trgm @ 0.7) surfaces the top 5 active plugins with similar names; the scan agent gets them in a POTENTIAL DUPLICATES prompt section and decides whether to flag as low_quality / spam / impersonation.
  • Cleanup: drops workflow, the @workflow/world@4.1.1 Bun patch, withWorkflow in next.config.mjs, the workflow TS plugin, and src/workflows/.

Migrations applied

  • 20260515_plugin_scan_queue.sql — creates the plugin_scans queue and locks pgmq_public.* EXECUTE down to service_role (closes the default-open PUBLIC/anon/authenticated grants).
  • 20260515_plugin_similar_search.sql — enables pg_trgm, GIN trigram index on plugins.name, find_similar_plugins(uuid, real, int) RPC granted only to service_role.

Both already applied to the live Cursor Directory project; pushing the branch is a no-op for the database.


Note

Medium Risk
Changes the production plugin security scanning pipeline and its retry/bury semantics, which can affect plugin publishing/flagging behavior and background job reliability. Also introduces new database migrations and cron-driven queue draining that depend on correct env/permissions.

Overview
Replaces the plugin security scan execution backend from the workflow package to a Supabase pgmq queue (plugin_scans) drained by a new /api/queue/plugin-scans/drain route (cron every minute) with VT-based retries and bury-after-5 behavior.

Updates all scan entry points (plugin submit/insert, update, admin rescan, and stuck-scan recovery cron) to enqueuePluginScan(...) and optionally kickDrainAfterResponse() for near-immediate processing outside the request lifecycle.

Enhances scan logic by adding duplicate-candidate detection via a new find_similar_plugins RPC (pg_trgm + GIN index) and passing those candidates into the Cursor agent prompt, while also introducing clearer fatal-vs-retryable error handling (FatalScanError) and queue permission hardening migrations for pgmq_public.

Reviewed by Cursor Bugbot for commit b99b94e. Bugbot is set up for automated code reviews on this repo. Configure here.

- Move plugin security scan off the `workflow` package onto a
  Postgres-native pgmq queue drained by a 1-minute Vercel cron
  (`/api/queue/plugin-scans/drain`, `maxDuration=800`, VT=900s,
  bury after 5 attempts).
- Server actions enqueue via `enqueuePluginScan` and fire a
  non-blocking `after()` kick at the drain route so new submissions
  scan within ms, not up to 60s.
- Add `find_similar_plugins` RPC (pg_trgm, threshold 0.7) and surface
  the top 5 candidates in the agent prompt so the security scan also
  catches near-duplicate name collisions.
- Drop the `workflow` package, the `@workflow/world` patch, the
  `withWorkflow` next.config wrapper, the workflow TS plugin, and the
  `src/workflows/` dir.
- Lock `pgmq_public.*` EXECUTE down to `service_role` (default-open
  on `PUBLIC`/`anon`/`authenticated` would let any browser holding the
  publishable key drain or stuff our queue).

Co-authored-by: Cursor <cursoragent@cursor.com>
@vercel
Copy link
Copy Markdown

vercel Bot commented May 15, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
cursor-directory Ready Ready Preview, Comment May 15, 2026 8:24am

Request Review

The 30 oversized plugin_components rows that were tripping ENAMETOOLONG
during prerender of /api/[slug] have been truncated to <= 80 chars and
the plugin_components_slug_length_check constraint is now enforced on the
live DB. This empty commit re-triggers the Vercel build.

Co-authored-by: Cursor <cursoragent@cursor.com>
Copy link
Copy Markdown

@cursor cursor Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes using high mode and found 4 potential issues.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit b99b94e. Configure here.

Comment thread README.md
Comment thread apps/cursor/src/lib/plugins/scan.ts
Comment thread apps/cursor/src/lib/plugins/scan.ts
Comment thread apps/cursor/src/app/api/queue/plugin-scans/drain/route.ts
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant